<template>
  <box title="工单统计" class="cursor-pointer">
    <!-- 日期选择 -->
    <template #title-right>
      <div class="flex">
        <div v-for="(item, index) in timeList" :key="index" class="text-[#ffffff] w-[26px] h-[26px]
                   "
             :class="selectTime == index ? 'bg-[url(@/assets/screenimg/samllIcon6.png)]' : 'bg-[url(@/assets/screenimg/samllIcon5.png)]'"
             @click="changeList(item, index)">
          <div class="text-center leading-[26px]">
            {{ isNullOrEmpty( item?.name ) }}
          </div>

        </div>
      </div>
    </template>
    <div class="h-[290px]">
      <pie :data="piedata"/>
    </div>
  </box>
</template>
<script lang="ts" setup>
import { isNullOrEmpty } from '@/utils/functions'
import {screenworkorder} from '@/api/screen/largeData'
import box from '@/views/large-data-screen/component/box.vue'
import pie from '@/views/large-data-screen/component/echarts/pie.vue'

const piedata = ref([])
const workOrderDT = ref(0)
const selectTime = ref(0) //选择时间
// 时间选择
const timeList = ref([
  {
    name: '月',
    id: 3
  },
  {
    name: '年',
    id: 4

  },

])
onMounted(() => {
  getscreeninspect()
})
//点击年月日
const changeList = (item, index) => {
  selectTime.value = index
  workOrderDT.value = item.id
  getscreeninspect()
}
//获取工单
const getscreeninspect = () => {
  screenworkorder({
    workOrderDT: workOrderDT.value,//工单处理日期类型 （0-全部 1 日 2周 3 月 4 年）
    workOrderTypeDT: 0 //工单类型统计日期类型  （0-全部   3 月 5 上月）

  }).then(res => {

    piedata.value = res.result.workOrderType


  })
}
</script>
